<!--{include file="tempbox/top.html"}-->
<body>
<!--{include file="tempbox/header.html"}-->
<!-- end of header -->
<!--{include file="tempbox/bignav.html"}-->
<style>
	.pubu{width:600px;float:left;position:relative;}
	.pubu li{float:left;padding:4px;background:white;border:1px solid #ECECEC;margin:0 3px 15px 10px;display:inline;width:176px;}
	.pbimg{float:left;display:inline;border:2px solid #F2F2F2;width: 172px;}
	.pbimg img{vertical-align:middle;width: 172px;}
	.pubu li p{float:left;height:25px;line-height:25px;}
	.pubu li p a{color:#707070;}
</style>
<div class="container bread">
	<a href="/temp.html" class="fs">经典模板</a><!--{if $smarty.get.id}-->->&nbsp;&nbsp;<!--{foreach from=$cate item=val}--><!--{if $val.cates==$smarty.get.id}--><!--{$val.catename}--><!--{/if}--><!--{/foreach}--><!--{/if}-->
</div>
<div id="main" class="container">
	<ul class="pubu" id="wrap">
	<!--{foreach from=$list item=val key=key}-->
		<li>
			<a href="/single-<!--{$val.id}-->.html" class="pbimg"><img src="<!--{$val.faceimg|imgdone:'s'}-->"/></a>
			<p><a href="/single-<!--{$val.id}-->.html"><!--{$val.title}--></a></p>
		</li>
	<!--{/foreach}-->
	</ul>
	<!--{include file="tempbox/single-side.html"}-->
</div>
<!--{include file="tempbox/footer.html"}-->
<!-- end funter -->
</body>
<script type="text/javascript">
var f = function()
{
	var t = this;
		t.cid = 'wrap';
		t.W = 200;
		t.loadFlag = true;
		t.id = 2;
	this.sort = function()
	{
		var h = [];
		var box = $('#' + t.cid).children('li');
		for(var i = 0; i < box.length; i++)
		{  
			var boxH = box.eq(i).height()+25;
			if(i < 3)
			{
				h[i] = boxH;
			}else{
				var minH = Math.min.apply({},h);
				var minKey = getminKey(h, minH);
					h[minKey] += boxH;
					
				box.eq(i).css({
					"position" : 'absolute',
					"top" : minH,
					"left" : minKey * t.W
				})
			}
		}
		$('#' + t.cid).css({'height':Math.max.apply({},h)})
		setTimeout(function(){t.loadFlag = true;},500);			
	}

	this.load = function()
	{
		t.loadFlag = false;
		$.ajax({
		   type: "POST",
		   url: "ajax.php",
		   data: 'action=temp&page='+t.id,
		   success: function(data){
			    var json = $.parseJSON(data);
				var html ='';
				for(var i=0;i<json.length;i++)
				{
					html += '<li><a href="/single-'+json[i].id+'.html" class="pbimg"><img src="'+json[i].img+'"/></a><p><a href="/single-'+json[i].id+'.html">'+json[i].name+'</a></p></li>';
				}
				$("#wrap").append(html);t.id++;t.sort();
		   }
		});		
	}
}
var F = new f;
	F.sort();
	
/* 返回数组中某一值的对应项数 */
function getminKey(s, v) {
        for(k in s) {
                if(s[k] == v) {
                        return k;
                }
        }
};

$(window).scroll(function () {
	var scrollTop = document.documentElement.scrollTop;
	var winH = $(window).height();
	var docH = $(document).height();

	if(scrollTop + winH > docH - 300)
	{
		F.loadFlag ? F.load() : '';
	}
});
</script>
</html>